VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOResumen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'---------------------------------------------------------------------------------------
' Module    : DAOResumen
' DateTime  : 30/11/2011 12:14
' Author    :
' Purpose   : Clase DAO Resumen
'---------------------------------------------------------------------------------------
Option Explicit
Private mvarConnection As utilConexion
Public Property Set Connection(ByVal vData As utilConexion)
    Set mvarConnection = vData
End Property

Public Function generarGuiaVentas(ndiaTrabajo As Integer) As Integer
On Error GoTo hnderr
Dim result As Integer
Dim sql As String
Dim rst As New Recordset
sql = "SELECT * from proc_guia_genera_salida('" + bparametro.bUsuarioActivo.sNombre + "'," + CStr(ndiaTrabajo) + ")"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
If Not rst.EOF Then
    If Not IsNull(rst.Fields(0)) Then result = rst.Fields(0)
End If
    generarGuiaVentas = result
hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
End Function

Public Function getBean(ByRef bean As bResumen) As Integer
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
sql = "SELECT scompania, ntotturno, ntotdia, ntotpendiente, ntotal from proc_resumen_lista('" + bean.bCompania.sRuc + "','" + bean.busuario.sNombre + "'," + CStr(bean.ndiaTrabajo) + ");"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
If Not rst.EOF Then
    If Not IsNull(rst.Fields("scompania")) Then bean.bCompania.sRuc = rst.Fields("scompania")
    If Not IsNull(rst.Fields("ntotturno")) Then bean.nTotTurno = rst.Fields("ntotturno") Else bean.nTotTurno = 0
    If Not IsNull(rst.Fields("ntotdia")) Then bean.nTotal = rst.Fields("ntotdia") Else bean.nTotal = 0
    If Not IsNull(rst.Fields("ntotpendiente")) Then bean.nTotPendientes = rst.Fields("ntotpendiente") Else bean.nTotPendientes = 0
    If Not IsNull(rst.Fields("ntotal")) Then bean.nTotGeneral = rst.Fields("ntotal") Else bean.nTotGeneral = 0
    getBean = UtilConstantes.OPT_DATOS_GUARDADOS
End If
hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
getBean = UtilConstantes.OPT_ERROR_ENCONTRADO
End Function
Public Function getResumenRptX(ByRef bean As bResumen) As Integer
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
sql = "SELECT  sum(ndocumentos) as ndocumentos, sum(ndocbasimponible) as ndocbasimponible,"
sql = sql + " sum(ndocigv) as ndocigv , sum(ndocservicio) as ndocservicio, sum(ndoctotal)as ndoctotal , sum(ndocanulados) as ndocanulados,"
sql = sql + " sum(ndoctotanuladas) as ndoctotanuladas, min(dminfecregistro )as dminfecregistro, max(dmaxfecregistro) as dmaxfecregistro from proc_reportex_lista('" + bean.bCompania.sRuc + "'," + CStr(bean.ndiaTrabajo) + ",'" + bean.bCompania.bPuntoVenta.sSerie + "','" + bean.busuario.sNombre + "' );"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
If Not rst.EOF Then
    'If Not IsNull(rst.Fields("ntipcomprobante")) Then bean.bTipDocumento.nCodigo = rst.Fields("ntipcomprobante")
   ' If Not IsNull(rst.Fields("stipcomprobante")) Then bean.bTipDocumento.sDescripcion = rst.Fields("stipcomprobante")
    If Not IsNull(rst.Fields("ndocumentos")) Then bean.nDocumentos = rst.Fields("ndocumentos").value
    If Not IsNull(rst.Fields("ndocbasimponible")) Then bean.nBaseRptX = rst.Fields("ndocbasimponible")
    If Not IsNull(rst.Fields("ndocigv")) Then bean.nIgvRptX = rst.Fields("ndocigv")
    If Not IsNull(rst.Fields("ndocservicio")) Then bean.nServicioRptX = rst.Fields("ndocservicio")
    If Not IsNull(rst.Fields("ndoctotal")) Then bean.nTotalRptX = rst.Fields("ndoctotal")
    'If Not IsNull(rst.Fields("ndocminticket")) Then bean.sMinTicket = rst.Fields("ndocminticket")
    'If Not IsNull(rst.Fields("ndocmaxticket")) Then bean.sMaxTicket = rst.Fields("ndocmaxticket")
    If Not IsNull(rst.Fields("ndocanulados")) Then bean.nAnulados = rst.Fields("ndocanulados")
    If Not IsNull(rst.Fields("ndoctotanuladas")) Then bean.nTotAnulados = rst.Fields("ndoctotanuladas")
    If Not IsNull(rst.Fields("dminfecregistro")) Then bean.dFecha = rst.Fields("dminfecregistro")
    getResumenRptX = UtilConstantes.OPT_DATOS_GUARDADOS
Else
    bean.nDocumentos = 0
    bean.nBaseRptX = 0
    bean.nIgvRptX = 0
    bean.nTotalRptX = 0
    bean.nAnulados = 0
    bean.nTotAnulados = 0
    getResumenRptX = UtilConstantes.OPT_DATOS_GUARDADOS
End If
hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
getResumenRptX = UtilConstantes.OPT_ERROR_ENCONTRADO
End Function
Public Function getResumenRptZ(ByRef bean As breporteZ) As Integer
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
sql = "SELECT ntipcomprobante, stipcomprobante, ndocumentos, ndocbasimponible, ndocigv, ndocservicio, ndoctotal, ndocminticket, ndocmaxticket , ndocanulados , ndoctotanuladas , dminfecregistro, dmaxfecregistro from proc_reportez_lista('" + bean.bCompania.sRuc + "'," + CStr(bean.ndiaTrabajo) + ",'" + bean.bCompania.bPuntoVenta.sSerie + "' );"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
While Not rst.EOF
    If Not IsNull(rst.Fields("ntipcomprobante")) Then bean.bTipDocumento.ncodigo = rst.Fields("ntipcomprobante")
    If Not IsNull(rst.Fields("stipcomprobante")) Then bean.bTipDocumento.sdescripcion = rst.Fields("stipcomprobante")
    If Not IsNull(rst.Fields("dminfecregistro")) Then bean.dMinFecRegistro = rst.Fields("dminfecregistro")
    If Not IsNull(rst.Fields("dmaxfecregistro")) Then bean.dMaxFecRegistro = rst.Fields("dmaxfecregistro")
    If bean.bTipDocumento.ncodigo = UtilConstantes.TIPO_DOCUMENTO_BOLETA Then
        If Not IsNull(rst.Fields("ndocumentos")) Then bean.nNumTickets = rst.Fields("ndocumentos")
        If Not IsNull(rst.Fields("ndocbasimponible")) Then bean.nBasImpTickets = rst.Fields("ndocbasimponible")
        If Not IsNull(rst.Fields("ndocigv")) Then bean.nIgvTickets = rst.Fields("ndocigv")
        If Not IsNull(rst.Fields("ndocservicio")) Then bean.nSerTickets = rst.Fields("ndocservicio")
        If Not IsNull(rst.Fields("ndoctotal")) Then bean.ntotTickets = rst.Fields("ndoctotal")
        If Not IsNull(rst.Fields("ndocminticket")) Then bean.nMinTicket = rst.Fields("ndocminticket")
        If Not IsNull(rst.Fields("ndocmaxticket")) Then bean.nMaxTicket = rst.Fields("ndocmaxticket")
        If Not IsNull(rst.Fields("ndocanulados")) Then bean.nAnuTickets = rst.Fields("ndocanulados")
        If Not IsNull(rst.Fields("ndoctotanuladas")) Then bean.nTotAnuTickets = rst.Fields("ndoctotanuladas")
    Else
        If Not IsNull(rst.Fields("ndocumentos")) Then bean.nNumFacturas = rst.Fields("ndocumentos")
        If Not IsNull(rst.Fields("ndocbasimponible")) Then bean.nBasImpFacturas = rst.Fields("ndocbasimponible")
        If Not IsNull(rst.Fields("ndocigv")) Then bean.nIgvFacturas = rst.Fields("ndocigv")
        If Not IsNull(rst.Fields("ndocservicio")) Then bean.nSerFacturas = rst.Fields("ndocservicio")
        If Not IsNull(rst.Fields("ndoctotal")) Then bean.nTotFacturas = rst.Fields("ndoctotal")
        If Not IsNull(rst.Fields("ndocminticket")) Then bean.nMinFactura = rst.Fields("ndocminticket")
        If Not IsNull(rst.Fields("ndocmaxticket")) Then bean.nMaxFactura = rst.Fields("ndocmaxticket")
        If Not IsNull(rst.Fields("ndocanulados")) Then bean.nAnuFacturas = rst.Fields("ndocanulados")
        If Not IsNull(rst.Fields("ndoctotanuladas")) Then bean.nTotAnuFacturas = rst.Fields("ndoctotanuladas")
    End If
    rst.MoveNext
Wend
    getResumenRptZ = UtilConstantes.OPT_DATOS_GUARDADOS
hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
getResumenRptZ = UtilConstantes.OPT_ERROR_ENCONTRADO
End Function
